capture log close
capture noisily log using "R:\Zentrale\ZB-S\Daten_FDSZ_Gastforscher\1_gafo\2016_0133\Table 7.log", replace
capture noisily log using "Table 7.log", replace

**** Load data in Stata
clear all
set more off
set maxvar 5000

capture noisily use "R:\Zentrale\ZB-S\Daten_FDSZ_Gastforscher\1_gafo\2016_0133\data\Bundesbank Discussion Paper\final_sample_03032023.dta", clear
capture noisily use "final_sample_03032023_pseudo.dta", clear



/* Deutsche Bundesbank checks that our results respect all confidentiality
   rules: If we wish to disclose a regression coefficient that identifies a 
   subset of banks, then this subset must contain a minimum number of banks 
   to comply with confidentiality rules. In regressions, this rule applies to 
   categorical regressors (including interacted ones). 

   The Bundesbank uses a self-written command to check compliance with the 
   confidentiality rules. This command does not always execute for 
   higher interactions (especially when the lower-level base effects are 
   absorbed by some FEs). For this reason, we generate a new variable 
   for each interaction term separately: */ 

gen DEU_AbrImp_AbrNImp_2 = 0
replace DEU_AbrImp_AbrNImp_2 = 1 if DEU_AbrImp_AbrNImp==2

gen sanctions_2_DEU_AbrImp_AbrNImp = sanctions * DEU_AbrImp_AbrNImp_2

gen FImp_FnImp_nFImp_nFnImp_1 = 0
replace FImp_FnImp_nFImp_nFnImp_1 = 1 if FImp_FnImp_nFImp_nFnImp==1
gen FImp_FnImp_nFImp_nFnImp_2 = 0
replace FImp_FnImp_nFImp_nFnImp_2 = 1 if FImp_FnImp_nFImp_nFnImp==2
gen FImp_FnImp_nFImp_nFnImp_3 = 0
replace FImp_FnImp_nFImp_nFnImp_3 = 1 if FImp_FnImp_nFImp_nFnImp==3

gen sanctions_1_FImp = sanctions * FImp_FnImp_nFImp_nFnImp_1
gen sanctions_2_FImp = sanctions * FImp_FnImp_nFImp_nFnImp_2
gen sanctions_3_FImp = sanctions * FImp_FnImp_nFImp_nFnImp_3


*** Regressions for Table 7

reghdfe lam100 sanctions sanctions_2_DEU_AbrImp_AbrNImp if INTY==4, absorb(systimeFE id) vce(cluster datum land CTRY)

reghdfe lam100 sanctions sanctions_1_FImp sanctions_2_FImp sanctions_3_FImp if INTY==4, absorb(systimeFE id) vce(cluster datum land CTRY)

reghdfe lam100 sanctions sanctions_2_DEU_AbrImp_AbrNImp if INTY==2, absorb(systimeFE id) vce(cluster datum land CTRY)

quietly eststo r1: reghdfe lam100 sanctions sanctions_1_FImp sanctions_2_FImp sanctions_3_FImp if INTY==2, absorb(systimeFE id) vce(cluster datum land CTRY)

* show only coeff estimates of the non-critical regressors (do not report sanctions_2_FImp sanctions_3_FImp):
esttab r1 , se unstack b(%10.3f) nogaps alignment(c) numbers nodepvars noomitted noobs nolabel star(* 0.10 ** 0.05 *** 0.01) scalars("N Obs." "r2 R2" "r2_a adjR2") sfmt(%9.0f %9.3f %9.3f) drop(sanctions_2_FImp sanctions_3_FImp _cons) title("dropped coeff of sanctions_2_FImp sanctions_3_FImp") nonotes 

* replace critical regressors and pool them into one dummy variable "notFATF_CTRY":
reghdfe lam100 sanctions sanctions_1_FImp c.sanctions#c.notFATF_CTRY if INTY==2, absorb(systimeFE id) vce(cluster datum land CTRY)



log close
